package com.example.demo.study;

public class Test4 {

    public static void main(String[] args) {
        String java = "JAVA";
        byte[] bytes = java.getBytes();
        for (byte aByte : bytes) {
            String binaryString = Integer.toBinaryString(aByte);
            System.out.print(binaryString + " ");
        }
        System.out.println();

        String binaryStr = "1001010 1000001 1010110 1000001";

        String[] split = binaryStr.split(" ");
        for (String s : split) {
            int i = Integer.parseInt(s, 2);
            System.out.println((char) i);
        }
    }
}
